/*
 * $Id: CharacterSheetPageImpl.java 8 2007-12-29 18:54:44Z aaron.day $
 */
package org.crazydays.wowarmory.page;


import java.net.URI;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.crazydays.wowarmory.IData;
import org.crazydays.wowarmory.WowArmoryException;
import org.crazydays.wowarmory.data.NameData;

/**
 * CharacterSheetPage
 */
public class CharacterSheetPageImpl
	extends AbstractPage
{
	/** page url */
	protected final static String PAGE_URL = "/character-sheet.xml";

	/** parameter: name */
	protected final static String PARAM_NAME = "n";

	/** parameter: realm */
	protected final static String PARAM_REALM = "r";

	/** name */
	protected String name;

	/** realm */
	protected String realm;

	/**
	 * CharacterSheetPageImpl constructor.
	 *
	 * @param baseUri Base uri
	 * @param name Name
	 * @param realm Realm
	 */
	public CharacterSheetPageImpl(URI baseUri, String name, String realm)
	{
		super(baseUri);
		setName(name);
		setRealm(realm);
	}

	/**
	 * CharacterSheetPageImpl constructor.
	 *
	 * @param baseUri Base uri
	 * @param name Name
	 * @param realm Realm
	 */
	public CharacterSheetPageImpl(String baseUri, String name, String realm)
	{
		super(baseUri);
		setName(name);
		setRealm(realm);
	}

	/**
	 * Set name.
	 *
	 * @param name Name
	 */
	public final void setName(String name)
	{
		this.name = name;
	}

	/**
	 * Get name.
	 *
	 * @return Name
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * Set realm.
	 *
	 * @param realm Realm
	 */
	public void setRealm(String realm)
	{
		this.realm = realm;
	}

	/**
	 * Get realm.
	 *
	 * @return Realm
	 */
	public String getRealm()
	{
		return realm;
	}

	/**
	 * Get page uri.
	 *
	 * @return Page uri
	 * @see AbstractPage#getPageUri()
	 */
	public URI getPageUri()
	{
		StringBuffer uri = new StringBuffer();

		// base uri
		uri.append(getBaseUri().toString());

		// page
		uri.append(PAGE_URL);

		// name
		uri.append("?");
		uri.append(getGetParameter(PARAM_NAME, getName()));

		// realm
		uri.append("&");
		uri.append(getGetParameter(PARAM_REALM, getRealm()));

		return URI.create(uri.toString());
	}
}
